﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:controls="clr-namespace:Framework.UI.Controls"
                    xmlns:local="clr-namespace:Framework.UI">
    <ResourceDictionary.MergedDictionaries>
        <ResourceDictionary Source="/Elysium;component/Themes/Generic.xaml"/>
        <ResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/FocusVisualStyle.xaml"/>
        <ResourceDictionary Source="/Framework.UI;component/Themes/WPF/Controls/Separator.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="DefaultListBoxItemStyle" BasedOn="{StaticResource {x:Type ListBoxItem}}" TargetType="{x:Type ListBoxItem}">
        <Setter Property="controls:ListBoxItemAttached.IsDeselectionEnabled" Value="True"/>
        <Setter Property="FocusVisualStyle" Value="{StaticResource {x:Static SystemParameters.FocusVisualStyleKey}}"/>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="{StaticResource MiddleLightBrush}"/>
                <Setter Property="Foreground" Value="{StaticResource ContrastBrush}"/>
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsEnabled" Value="True"/>
                    <Condition Property="IsSelected" Value="True"/>
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="Background" Value="{StaticResource AccentBrush}"/>
                    <Setter Property="Foreground" Value="{StaticResource ContrastBrush}"/>
                </MultiTrigger.Setters>
            </MultiTrigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsEnabled" Value="False"/>
                    <Condition Property="IsSelected" Value="True"/>
                </MultiTrigger.Conditions>
                <MultiTrigger.Setters>
                    <Setter Property="Background" Value="{StaticResource DisabledBrush}"/>
                    <Setter Property="Foreground" Value="{StaticResource ContrastBrush}"/>
                </MultiTrigger.Setters>
            </MultiTrigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="FishEyeListBoxItemStyle" TargetType="{x:Type ListBoxItem}">
        <Setter Property="Background" Value="{StaticResource TransparentBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource TransparentBrush}"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=Foreground, Mode=OneWay}"/>
        <Setter Property="FontFamily" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=FontFamily, Mode=OneWay}"/>
        <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=FontSize, Mode=OneWay}"/>
        <Setter Property="FontStretch" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=FontStretch, Mode=OneWay}"/>
        <Setter Property="FontStyle" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=FontStyle, Mode=OneWay}"/>
        <Setter Property="FontWeight" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=FontWeight, Mode=OneWay}"/>
        <Setter Property="TextOptions.TextFormattingMode" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=(TextOptions.TextFormattingMode), Mode=OneWay}"/>
        <Setter Property="TextOptions.TextRenderingMode" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=(TextOptions.TextRenderingMode), Mode=OneWay}"/>
        <Setter Property="RenderOptions.ClearTypeHint" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=(RenderOptions.ClearTypeHint), Mode=OneWay}"/>
        <Setter Property="Focusable" Value="True"/>
        <Setter Property="FocusVisualStyle" Value="{StaticResource {x:Static SystemParameters.FocusVisualStyleKey}}"/>
        <Setter Property="HorizontalContentAlignment" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=HorizontalContentAlignment, Mode=OneWay}"/>
        <Setter Property="VerticalContentAlignment" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=VerticalContentAlignment, Mode=OneWay}"/>
        <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type Selector}}, Path=Padding, Mode=OneWay}"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Border x:Name="Bd"
                            Background="{TemplateBinding Background}"
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            TextBlock.Foreground="{TemplateBinding Foreground}"
                            TextBlock.FontSize="{TemplateBinding FontSize}"
                            TextBlock.FontStretch="{TemplateBinding FontStretch}"
                            TextBlock.FontStyle="{TemplateBinding FontStyle}"
                            TextBlock.FontWeight="{TemplateBinding FontWeight}"
                            TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}"
                            TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}"
                            RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}"
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <VisualStateManager.VisualStateGroups>
                            <VisualStateGroup x:Name="CommonStates">
                                <VisualState x:Name="Normal">
                                    <Storyboard FillBehavior="HoldEnd">
                                        <DoubleAnimation Duration="0:0:0.3"
                                                         Storyboard.TargetName="Bd"
                                                         Storyboard.TargetProperty="LayoutTransform.ScaleX"
                                                         To="1"/>
                                        <DoubleAnimation Duration="0:0:0.3"
                                                         Storyboard.TargetName="Bd"
                                                         Storyboard.TargetProperty="LayoutTransform.ScaleY"
                                                         To="1"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="MouseOver">
                                    <Storyboard FillBehavior="HoldEnd">
                                        <DoubleAnimation Duration="0:0:0.3"
                                                         Storyboard.TargetName="Bd"
                                                         Storyboard.TargetProperty="LayoutTransform.ScaleX"
                                                         To="1.2"/>
                                        <DoubleAnimation Duration="0:0:0.3"
                                                         Storyboard.TargetName="Bd"
                                                         Storyboard.TargetProperty="LayoutTransform.ScaleY"
                                                         To="1.2"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Disabled">
                                    <Storyboard FillBehavior="HoldEnd">
                                        <DoubleAnimation Duration="0:0:0.3"
                                                         Storyboard.TargetName="Bd"
                                                         Storyboard.TargetProperty="LayoutTransform.ScaleX"
                                                         To="0.75"/>
                                        <DoubleAnimation Duration="0:0:0.3"
                                                         Storyboard.TargetName="Bd"
                                                         Storyboard.TargetProperty="LayoutTransform.ScaleY"
                                                         To="0.75"/>
                                    </Storyboard>
                                </VisualState>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="SelectionStates">
                                <VisualState x:Name="Unselected">
                                    <Storyboard FillBehavior="HoldEnd">
                                        <DoubleAnimation Duration="0:0:0.3"
                                                         Storyboard.TargetName="Bd2"
                                                         Storyboard.TargetProperty="RenderTransform.ScaleX"
                                                         To="1"/>
                                        <DoubleAnimation Duration="0:0:0.3"
                                                         Storyboard.TargetName="Bd2"
                                                         Storyboard.TargetProperty="RenderTransform.ScaleY"
                                                         To="1"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="Selected">
                                    <Storyboard FillBehavior="HoldEnd">
                                        <DoubleAnimation Duration="0:0:0.3"
                                                         Storyboard.TargetName="Bd2"
                                                         Storyboard.TargetProperty="RenderTransform.ScaleX"
                                                         To="1.4"/>
                                        <DoubleAnimation Duration="0:0:0.3"
                                                         Storyboard.TargetName="Bd2"
                                                         Storyboard.TargetProperty="RenderTransform.ScaleY"
                                                         To="1.4"/>
                                    </Storyboard>
                                </VisualState>
                                <VisualState x:Name="SelectedUnfocused"/>
                            </VisualStateGroup>
                            <VisualStateGroup x:Name="FocusStates">
                                <VisualState x:Name="Unfocused"/>
                                <VisualState x:Name="Focused"/>
                            </VisualStateGroup>
                        </VisualStateManager.VisualStateGroups>
                        <Border.LayoutTransform>
                            <ScaleTransform CenterX="0.5"
                                            CenterY="0.5"
                                            ScaleX="1"
                                            ScaleY="1"/>
                        </Border.LayoutTransform>
                        <Border x:Name="Bd2"
                                RenderTransformOrigin="0.5, 0.5">
                            <Border.RenderTransform>
                                <ScaleTransform CenterX="0.5"
                                                CenterY="0.5"
                                                ScaleX="1"
                                                ScaleY="1"/>
                            </Border.RenderTransform>
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              Margin="{TemplateBinding Padding}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Border>
                    </Border>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Setter Property="Foreground" Value="{StaticResource MiddleLightBrush}"/>
                        </Trigger>
                        <Trigger Property="IsSelected" Value="True">
                            <Setter Property="Foreground" Value="{StaticResource AccentBrush}"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{StaticResource DisabledBrush}"/>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    
    <Style x:Key="DraggableListBoxItemStyle" BasedOn="{StaticResource DefaultListBoxItemStyle}" TargetType="{x:Type ListBoxItem}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListBoxItem}">
                    <Border Background="{TemplateBinding Background}" 
                            BorderBrush="{TemplateBinding BorderBrush}" 
                            BorderThickness="{TemplateBinding BorderThickness}" 
                            TextBlock.Foreground="{TemplateBinding Foreground}" 
                            TextBlock.FontSize="{TemplateBinding FontSize}" 
                            TextBlock.FontStretch="{TemplateBinding FontStretch}" 
                            TextBlock.FontStyle="{TemplateBinding FontStyle}" 
                            TextBlock.FontWeight="{TemplateBinding FontWeight}" 
                            TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" 
                            TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" 
                            RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" 
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <controls:AdornedControl IsAdornerVisible="{Binding ElementName=MoveUpBorder, Path=(local:DragCommand.IsDragOver)}">
                            <controls:AdornedControl.AdornerContent>
                                <Separator Style="{StaticResource HorizontalDragSeparatorStyle}"
                                           VerticalAlignment="Top"/>
                            </controls:AdornedControl.AdornerContent>
                            <controls:AdornedControl IsAdornerVisible="{Binding ElementName=MoveDownBorder, Path=(local:DragCommand.IsDragOver)}">
                                <controls:AdornedControl.AdornerContent>
                                    <Separator Style="{StaticResource HorizontalDragSeparatorStyle}"
                                               VerticalAlignment="Bottom"/>
                                </controls:AdornedControl.AdornerContent>
                                <Grid local:DragManager.ContentTemplate="{TemplateBinding controls:ListBoxItemAttached.MoveDragContentTemplate}" 
                                      local:DragManager.Data="{Binding}"
                                      local:DragManager.Effects="Move"
                                      local:DragManager.Format="{TemplateBinding controls:ListBoxItemAttached.MoveDragFormat}"
                                      Background="{StaticResource TransparentBrush}">
                                    <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                                      Margin="{TemplateBinding Padding}"
                                                      VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                                    <Grid local:DragViewer.Format="{TemplateBinding controls:ListBoxItemAttached.MoveDragFormat}"
                                          IsHitTestVisible="{Binding Path=(local:DragViewer.IsDragging), RelativeSource={RelativeSource Self}}">
                                        <Grid.RowDefinitions>
                                            <RowDefinition Height="*"/>
                                            <RowDefinition Height="*"/>
                                        </Grid.RowDefinitions>
                                        <Border x:Name="MoveUpBorder" 
                                                local:DragCommand.Command="{TemplateBinding controls:ListBoxItemAttached.MoveAboveCommand}"
                                                local:DragCommand.Format="{TemplateBinding controls:ListBoxItemAttached.MoveDragFormat}"
                                                AllowDrop="True"
                                                Background="{StaticResource TransparentBrush}"
                                                Focusable="False"/>
                                        <Border x:Name="MoveDownBorder" 
                                                Grid.Row="1"
                                                local:DragCommand.Command="{TemplateBinding controls:ListBoxItemAttached.MoveBelowCommand}"
                                                local:DragCommand.Format="{TemplateBinding controls:ListBoxItemAttached.MoveDragFormat}"
                                                AllowDrop="True"
                                                Background="{StaticResource TransparentBrush}"
                                                Focusable="False"/>
                                    </Grid>

                                </Grid>
                            </controls:AdornedControl>
                        </controls:AdornedControl>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

</ResourceDictionary>